function updateType() {
    var selected = $("#typeTable").bootstrapTreeTable("getSelections");
    var selected_length = selected.length;
    if (!selected_length) {
        $MB.n_warning('请勾选需要修改的类型！');
        return;
    }
    if (selected_length > 1) {
        $MB.n_warning('一次只能修改一个类型！');
        return;
    }
    var typeId = selected[0].id;
    $.post(ctx + "shopping/type/getType", { "typeId": typeId }, function(r) {
        if (r.code == 0) {
            var $form = $('#type-add');
            $form.modal();
            var type = r.msg;
            $("#type-add-modal-title").html('修改类型');
            $form.find("input[name='typeName']").val(type.typeName);
            $form.find("input[name='oldTypeName']").val(type.typeName);
            $form.find("input[name='icon']").val(type.icon);
            $form.find("input[name='id']").val(type.id);
            $('#typeTree').jstree('select_node', type.parentId, true);
            $('#typeTree').jstree('disable_node', type.typeId);
            $("#type-add-button").attr("name", "update");
        } else {
            $MB.n_danger(r.msg);
        }
    });
}